﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ServiceModel;
using MonitorServer;
using System.ServiceModel.Description;

namespace MonitorHost
{
    internal class Host
    {
        static ServiceHost serviceHost = null;

        internal static void StartService()
        {
            serviceHost = new ServiceHost(typeof(MessageQueueService));
            //serviceHost.AddServiceEndpoint(typeof(IMessageQueue), new BasicHttpBinding(), "http://127.0.0.1:8888/mqservice");
            //if (serviceHost.Description.Behaviors.Find<ServiceMetadataBehavior>() == null)
            //{
            //    ServiceMetadataBehavior behavior = new ServiceMetadataBehavior();
            //    behavior.HttpGetEnabled = true;
            //    behavior.HttpGetUrl = new Uri("http://127.0.0.1:8888/mqservice/metadata");
            //    serviceHost.Description.Behaviors.Add(behavior);
            //}
            serviceHost.Open();
        }
        internal static void StopService()
        {
            if (serviceHost.State != CommunicationState.Closed)
                serviceHost.Close();
        }
    }
}
